from direct.actor.Actor import Actor
from direct.showbase.DirectObject import DirectObject
from panda3d.core import NodePath, PandaNode
from panda3d.physics import *
from pandac.PandaModules import *

class Acorn(DirectObject):
    def __init__(self):
        self._weight = 1
        
        # Physics
        self._actorNode = ActorNode('AcornNodePhysics')
        #self._actorNode.getPhysicsObject().setMass(self._weight)
        #base.physicsMgr.attachPhysicalNode(self._actorNode)
        
        # Main nodepath node path
        self.nodepath = NodePath('AcornNodePath').attachNewNode(self._actorNode)
        self.nodepath.reparentTo(render)
        
        # Model
        self._acornTex = loader.loadTexture("models/acorn.png")
        self._acornModel = loader.loadModel("models/acorn")
        self._acornModel.setTexture(self._acornTex)
        self._acornModel.reparentTo(self.nodepath)
        self._acornModel.setScale(0.5)
        self._acornModel.setPos(0.2, -0.1, -0.2)
        #self._acornModel.setTwoSided(True)
        #self._acornModel.setDepthWrite(True)
        
        # Collision
        self.collider = self.nodepath.attachNewNode(CollisionNode('AcornCollision'))
        self.collider.node().addSolid(CollisionSphere(0, 0, 0, 2.25))
        #self.collider.show() # Debugging
        base.cTrav.addCollider(self.collider, base.collHandler)
        base.collHandler.addCollider(self.collider, self.nodepath)
    ############################################################################
    def Start(self):
        base.physicsMgr.attachPhysicalNode(self._actorNode)
    ############################################################################
    